package com.huawei.appgallery.foundation.launcher.api;

import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import androidx.annotation.NonNull;
import com.huawei.hms.framework.network.restclient.hwhttp.dns.DnsConfig;
import o.ceg;
import o.dky.j;
import o.Logger;
import o.evk;

public abstract class AbsLaunchInterceptor implements ceg {
    private int ˏ = 0;

    public boolean launchByPackage(@NonNull Context context, Intent intent, @NonNull String str, String str2) {
        if (intent == null) {
            return false;
        }
        if (!(context instanceof Activity)) {
            intent.addFlags(268435456);
        }
        try {
            context.startActivity(intent);
            return true;
        } catch (SecurityException e) {
            Logger.e("AppLauncher", new StringBuilder(DnsConfig.MAX_CACHE_ENTRIES).append("launchIntent SecurityException: [").append(str).append("] intent:").append(intent).append(" , error:").append(e.toString()).toString());
            return false;
        } catch (ActivityNotFoundException e2) {
            Logger.e("AppLauncher", new StringBuilder(DnsConfig.MAX_CACHE_ENTRIES).append("launchIntent ActivityNotFoundException: [").append(str).append("] intent:").append(intent).append(" , error:").append(e2.toString()).toString());
            return false;
        }
    }

    public void interceptorResult(String str, Context context) {
        if (1 == this.ˏ) {
            evk.ˏ(context.getResources().getString(j.ˋ, new Object[]{str}));
        } else if (-1 == this.ˏ) {
            evk.ˏ(context.getResources().getString(j.ॱʻ));
        } else if (2 == this.ˏ) {
            evk.ˏ(context.getResources().getString(j.ˈॱ));
        }
    }

    public int getLaunchResult() {
        return this.ˏ;
    }

    public void setLaunchResult(int i) {
        this.ˏ = i;
    }
}
